#include <bits/stdc++.h>
#define _for(i, a, b)  for (int i = (a); i <= (b); i ++ )
#define ll long long
using namespace std;
namespace IO {
	const int LIM = 1e5;
	static char buf[LIM], * p1 = buf, * p2 = buf, obuf[LIM], * p3 = obuf, cc[20];
	#define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, LIM, stdin), p1 == p2) ? EOF : * p1 ++ )
	#define pc(x) (p3 - obuf < LIM) ? ( * p3 ++ = x) : (fwrite(obuf, p3 - obuf, 1, stdout), p3 = obuf, * p3 ++ = x)
	inline int rd() {
		int val = 0, sgn = 1; char ch = gc();
		for ( ; ch < '0' || ch > '9'; ch = gc())  if (ch == '-')  sgn = - 1;
		for ( ; ch >= '0' && ch <= '9'; ch = gc())  val = (val << 3) + (val << 1) + (ch ^ 48); return (val * sgn);
	}
	inline void wt(int x, char c) {
		if ( ! x)  pc('0'); int len = 0;
		if (x < 0)  x = - x, pc('-');
		while (x)  cc[len ++ ] = x % 10 | '0', x /= 10;
		while (len -- )  pc(cc[len]); pc(c);
	}
} using namespace IO;
const int N = 1e6 + 5;
int n, q, L[N], R[N], vis[N]; unordered_map<ll, int> id; map<pair<int, int>, int> cnt, cnt_2;
inline ll ID(int l, int r, int k) { return 917120411ll * l + 998442353ll * r + k; }
struct Segment_Tree {
	#define lc (p << 1)
	#define rc (p << 1 | 1)
	#define mid ((tr[p].l + tr[p].r) >> 1)
	struct Tree { int l, r, tag, val; } tr[N << 2];
	inline int len(int p) { return tr[p].r - tr[p].l + 1; }
	inline bool In(int p, int l, int r) { return l <= tr[p].l && tr[p].r <= r; }
	inline void push_tag(int p, int k) { tr[p].val += k, tr[p].tag += k; }
	inline void push_down(int p) { if (tr[p].tag)  push_tag(lc, tr[p].tag), push_tag(rc, tr[p].tag), tr[p].tag = 0; }
	inline void push_up(int p) { tr[p].val = max(tr[lc].val, tr[rc].val); }
	void build(int p, int l, int r) {
		tr[p].l = l, tr[p].r = r;
		if (l ^ r)  build(lc, l, mid), build(rc, mid + 1, r);
	}
	void update(int p, int l, int r, int k) {
		if (l > r)  return ;
		if (In(p, l, r))  return push_tag(p, k); push_down(p);
		if (l <= mid)  update(lc, l, r, k);
		if (r > mid)  update(rc, l, r, k); push_up(p);
	}
	int query(int p, int l, int r) {
		if (In(p, l, r))  return tr[p].val; push_down(p); int res = 0;
		if (l <= mid)  res = max(res, query(lc, l, r));
		if (r > mid)  res = max(res, query(rc, l, r)); return res;
	}
	#undef lc
	#undef rc
	#undef mid
} SGT;

int main() {
	ios :: sync_with_stdio(false), cin.tie(0), cout.tie(0);
	q = rd(); int l, r, mid, x, val, pos_l, pos_r, t = 0; char op; SGT.build(1, 1, N - 5);
	while (q -- ) {
		op = gc(), l = rd(), r = rd();
		if (op == 'A')  n ++ , t ++ , L[n] = l, R[n] = r, id[ID(l, r, ++ cnt[make_pair(l, r)])] = n, vis[n] = 1, SGT.update(1, l, r - 1, 1);
		else  t -- , vis[x = id[ID(l, r, ++ cnt_2[make_pair(l, r)])]] = 0, SGT.update(1, L[x], R[x] - 1, - 1); val = SGT.tr[1].val, l = 1, r = N - 5, pos_l = pos_r = 0;
		if (val ^ t) {
			
		} else {
			while (l <= r) {
				mid = (l + r) >> 1;
				if (SGT.query(1, 1, mid) == val)  pos_l = mid, r = mid - 1;
				else  l = mid + 1;
			} l = pos_l, r = N - 5;
			while (l <= r) {
				mid = (l + r) >> 1;
				if (SGT.query(1, mid, N - 5) == val)  pos_r = mid, l = mid + 1;
				else  r = mid - 1;
			} l = 0, r = N;
			_for (i, 1, n)  if (vis[i]) {
				if (L[i] == pos_l && pos_r <= R[i] - 1)  r = min(r, R[i] - 1);
				if (L[i] <= pos_l && pos_r == R[i] - 1)  l = max(l, L[i]);
			} wt(r - l + 1, '\n');
			cerr << "fuck " << val << " " << pos_l << " " << pos_r << " " << l << " " << r << "\n";
		}
	}
	return fwrite(obuf, p3 - obuf, 1, stdout), 0;
}

